Is there a way to make `enum` type to be unsigned?
Posted
by Kirill V. Lyadvinsky
on Stack Overflow
See other posts from Stack Overflow
or by Kirill V. Lyadvinsky
Published on 2010-04-28T18:15:55Z
Indexed on
2010/04/28
18:27 UTC
Read the original article
Hit count: 317
Is there a way to make enum
type to be unsigned? The following code gives me a warning about signed/unsigned comparison.
enum EEE {
X1 = 1
};
int main()
{
size_t x = 2;
EEE t = X1;
if ( t < x ) std::cout << "ok" << std::endl;
return 0;
}
I've tried to force compiler to use unsigned underlying type for enum with the following:
enum EEE {
X1 = 1,
XN = 18446744073709551615LL
};
But that still gives the warning.
© Stack Overflow or respective owner